class Dog:
    name = ''
    age = 0
    def __init__(self, name, age):
        '''初始化属性'''
        self.name = name
        self.age = age

    def sit(self):
        """模拟⼩狗收到命令时坐下"""
        print(f"{self.name} is now sitting.")

    def roll_over(self):
        """模拟⼩狗收到命令时打滚"""
        print(f"{self.name} rolled over!")

class ZhongHuaDog(Dog):
    """中华田园犬"""
    def __init__(self, name, age, color='brown'):
        super().__init__(name, age)  # 调用父类的构造方法
        self.color = color

    def bark(self):
        """模拟中华田园犬叫声"""
        print(f"{self.name} says: Woof Woof!")

my_dog = Dog('Willie', 6)
print(f"My dog's name is {my_dog.name}.")
print(f"My dog is {my_dog.age} years old.")
my_dog.sit()
my_dog.roll_over()

# 属性可直接通过实例访问，也可以给属性赋值，没有java中的final 和 static修饰符
my_dog.age = 7

zhonghua_dog = ZhongHuaDog('阿黄', 6, '黄色')
print(f"My ZhongHua dog's name is {zhonghua_dog.name}, color is {zhonghua_dog.color}.")